import copy

n, m = map(int, input().split())
juzhen = []
for i in range(n):
    a = list(map(int, input().split()))
    juzhen.append(a)
copy_juzhen = copy.deepcopy(juzhen)
for i in range(1, n-1):
    for j in range(1, m-1):
        copy_juzhen[i][j] = round(
            (juzhen[i][j]+juzhen[i-1][j]+juzhen[i+1][j]+juzhen[i][j-1]+juzhen[i][j+1])/5)
for i in range(n):
    for j in range(m):
        print(copy_juzhen[i][j], end=" ")
    print("")

